## Initialize workspace.
# Remove objects.
rm(list = ls(all = TRUE))

## Generate data.
# Create count object storing count data.
count <- as.matrix(c(1547, 54, 2346))

# Convert count object to an object storing percentages.
perc <- sapply(count, function (x) x/sum(count))

# Create a cumulative percentage object.
cum_perc <- cumsum(perc)

# Create separate objects for the plotting of each proportion.
power_x <- c(0, rep(.74, 2), 0)
both_x <- c(.74, rep(.96, 2), .74)
weap_x <- c(.96, rep(1, 2), .96)

# Create an object representing the y-axis plotting points for each polygon.
plot_y <- c(2.25, 2.25, 3, 3)

# Open new .pdf file.
setEPS()
postscript("fgc1.eps", width = 10, height = 3)

# Modify graphical parameters (margins).
par(mar = c(0, 6, 6, 1))

# Create an empty plot.
plot(1, type = "n", xlab = "", ylab = "", xlim = c(0, 1), ylim = c(1.5, 3), axes = FALSE)

# Create polygons representing each proportion.
polygon(power_x, plot_y, col = "#FF8F37", border = "white")
polygon(both_x, plot_y, col = "steelblue3", border = "white")
polygon(weap_x, plot_y, col = "gray", border = "white")

# Create an axis and tick and axis labels.
axis(side = 3, at = seq(0, 1, .1), labels = FALSE)
text(x = seq(0, 1, .2), y = par("usr")[4] + .2, labels = c("0%", "20%", "40%", "60%", "80%", "100%"), xpd = TRUE)
mtext(text = "Proportion of Responses", side = 3, line = 2.5, cex = 1.25, font = 2)

# Add text denoting the percentage number associated of each proportion.
text(x = .74/2, y = 2.2, pos = 1, cex = 2, labels = "74%", col = "#FF8F37", font = 2)
text(x = .85, y = 2.2, pos = 1, cex = 2, labels = "22%", col = "steelblue3", font = 2)
text(x = .98, y = 2.2, labels = "4%", pos = 1, cex = 2, col = "grey", font = 2, xpd = TRUE)

# Add a legend.
leg = legend(x = -.16,, y = 2.625, legend = c("Oppose", "Support", "Prefer not\nto answer"), xpd = TRUE, 
	pch = 16, col = c("#FF8F37", "steelblue3", "grey"), box.lty = 0, cex = .9, y.intersp = 1.5, yjust = .5)

# Close the device.
dev.off()
